<template>
	<view class="userinfo">
		<view class="info_nickname">
			<view class="nickname_left"> id: </view>
			<view class="nickname_right">
				<input v-model="id" :placeholder="shopinfo.id" />
			</view>
		</view>

		<view class="info_nickname">
			<view class="nickname_left"> 商家名称: </view>
			<view class="nickname_right">
				<input v-model="shopName" :placeholder="shopinfo.shopName" />
			</view>
		</view>

		<view class="info_nickname">
			<view class="nickname_left"> 商家描述: </view>
			<view class="nickname_right">
				<input v-model="shopDescription" :placeholder="shopinfo.shopDescription" />
			</view>
		</view>
		
		<view class="info_nickname">
			<view class="nickname_left"> 商家楼层: </view>
			<view class="nickname_right">
				<input v-model="floor" :placeholder="shopinfo.floor" />
			</view>
		</view>

		<view class="info_nickname">
			<view class="nickname_left"> 商家地址: </view>
			<view class="nickname_right">
				<input v-model="shopAddress" :placeholder="shopinfo.shopAddress" />
			</view>
		</view>

		<view class="info_nickname">
			<view class="nickname_left"> 营业时间: </view>
			<view class="nickname_right">
				<input v-model="workTime" :placeholder="shopinfo.workTime" />
			</view>
		</view>

		<view class="info_nickname">
			<view class="nickname_left"> 店铺评分: </view>
			<view class="nickname_right">
				<input v-model="shopScore" :placeholder="shopinfo.shopScore" />
			</view>
		</view>

		<view class="info_nickname">
			<view class="nickname_left">状态(无法修改): </view>
			<view class="nickname_right">
				<input :placeholder="shopinfo.is_deleted == 0?'未删除':'已删除'" />
			</view>
		</view>
		<view class="btn-wrap">
			<button type="warn" class="btn" @click="saveinfo">保存</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				floor: "",
				shopScore: '',
				workTime: '',
				shopAddress: '',
				shopDescription: '',
				shopName: '',
				shopId: '',
				id: '',
				userAccount: '',
				userRole: '',
				imgUrl: '',
				userId: '',
				email: '',
				stuNum: '',
				avatar: '',
				nickname: '',
				username: '',
				avatar: '',
				name: '',
				examinationTypeArray: ['男', '女'],
				examinationTypeIndex: 0,
				examinationTypeArrayType: '',
				phone: '',
				number: 2,
				flag: false,
				shopinfo: [],
			}
		},
		onLoad(query) {
			this.shopId = query.shopId;
			this.getShopinfo();
		},
		methods: {
			saveinfo: function() {
				let that = this;
				let data = {
					id: that.shopId,
					shopName: that.shopName,
					shopDescription: that.shopDescription,
					shopAddress: that.shopAddress,
					workTime: that.workTime,
					shopScore: that.shopScore,
					floor: that.floor
				}
				that.$ajax(that.$url.updateShopById, "POST", data, function(resp) {
					uni.showToast({
						icon: "none",
						title: "保存成功！"
					})
					setTimeout(() => {
						uni.navigateBack()
					}, 500)
				})
			},
			getShopinfo() {
				let that = this;
				this.url = uni.getStorageSync('url');
				let collect = uni.getStorageSync('collect');
				this.collectNum = collect.length;
				let data = {
					shopId: that.shopId
				}
				this.$ajax(this.$url.searchShopById, 'POST', data, function(resp) {
					that.shopinfo = resp.data.result
				})
			},
			// 绑定输入监听事件
			onName(event) {
				const {
					detail
				} = event
				this.username = detail.value
			},
			change(e) {
				console.log('e:', e)
			},
			examinationType(e) {
				this.examinationTypeIndex = e.target.value
				this.examinationTypeArrayType = this.examinationTypeArray[this.examinationTypeIndex]
			},
			changenumber() {
				this.number = 1
				this.flag = true
			},
			onPhone(event) {
				const {
					detail
				} = event
				this.phone = detail.value
			}
		}
	}
</script>

<style lang="scss">
	.other {
		margin: 10rpx;
		height: 190rpx;
		// width: 90%;
		border-radius: 20rpx;
		background-color: #fff;

		.other_addres {
			height: 60rpx;
			padding: 20rpx 20rpx;
			border-bottom: 1rpx dashed gainsboro;
			display: flex;
			justify-content: space-between;

			image {
				width: 50rpx;
			}
		}
	}

	button::after {
		border-top: none;
		border-left: none;
		border-right: none;
		border-radius: 0;
	}

	.userinfo {
		font-size: 34rpx;
		font-weight: 400;
		color: #333333;
		height: 100%;
		position: relative;

		.form {
			background-color: #ffffff;
		}

		.avatar-wrap {
			border: 0;
			background-color: #ffffff;
			height: 158rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 0 32rpx;

			.avatar {
				margin-right: 10rpx;
			}

			.ipt {
				display: flex;
				align-items: center;
			}

			img {
				width: 118rpx;
				height: 118rpx;
			}
		}

		.info_nickname {
			border-bottom: 1px solid #e9e9e9;
			height: 112rpx;
			background: #ffffff;
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 0 32rpx;
			// justify-content: space-between;

			.nickname_left {}

			.nickname_right {
				input {
					text-align: right;
				}
			}

			.gender {
				display: flex;
				align-items: center;
				justify-content: center;
			}
		}

		.btn-wrap {
			position: absolute;
			// bottom: 50rpx;
			width: 100%;
			text-align: center;

			.btn {
				width: 690rpx;
				height: 88rpx;
			}
		}
	}
</style>